import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/pages/HomeView.vue'
import AboutView from '@/pages/AboutView.vue'
import UserInfoPage from '@/pages/user/UserInfoPage.vue'
import UserPwdInfoPage from '@/pages/user/UserPwdInfoPage.vue'
import UserManagePage from '@/pages/admin/UserManagePage.vue'
import ACCESS_ENUM from '@/access/accessEnum.ts'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  scrollBehavior(to, from, savedPosition) {
    // 如果有保存的位置（比如浏览器前进后退），则恢复到保存的位置
    if (savedPosition) {
      return savedPosition
    }
    // 否则滚动到页面顶部
    return { top: 0, behavior: 'smooth' }
  },
  routes: [
    { path: '/', name: '主页', component: HomeView, },
    { path: '/about', name: '关于', component: AboutView, },
    { path: '/user/info', name: '个人信息', component: UserInfoPage, },
    { path: '/user/pwd', name: '修改密码', component: UserPwdInfoPage, },
    { path: '/admin/userManage', name: '用户管理', component: UserManagePage,
      meta:{access:ACCESS_ENUM.ADMIN} },

    // { path: '/admin/pictureManage', name: '图片管理', component: PictureManagePage, },
    // { path: '/picture/add', name: '创建图片', component: PictureAddPage, },
    // { path: '/picture/add/batch', name: '批量创建图片', component: PictureBatchAddPage, },
    // { path: '/picture/:id', name: '图片详情', component: PictureInfoPage, props: true,  },
  ],
})

export default router
